package com.cloud.code.真题;

import java.util.*;

public class Demo29 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();

        String[] split = line.split(",");
        List<String> list = new ArrayList<>();
        for (int i = 0; i < split.length; i++) {
            for (int j = 0; j < split.length; j++) {
                if (i == j) {
                    continue;
                }
                for (int k = 0; k < split.length; k++) {
                    if (k == i || k == j) {
                        continue;
                    }

                    list.add(split[i] + split[j] + split[k]);

                }
            }
        }

        Collections.sort(list, Comparator.comparingInt(Integer::parseInt));
        System.out.println(list.get(0));


    }

    private static void dfs(String[] split, int length, int depth, List<String> list, Deque<String> deque, boolean[] used) {

        if (length == depth) {
            String s = Arrays.toString(new Deque[]{deque}).replaceAll("\\W+", "");
            list.add(s);
            return;
        }

        for (int i = 0; i < length; i++) {
            if (used[i]) {
                continue;
            }

            used[i] = true;
            deque.addLast(split[i]);
            dfs(split, length, depth + 1, list, deque, used);
            deque.removeLast();
            used[i] = false;
        }
    }
}
